﻿<!-- #include file="../Include/Admin_Onlogin.asp" -->
<%
Data_Name = "{prefix}Admin_Group"
strFileName = "Admin_AdminGroup.asp"
Dim sqlAuth, rsAuth, PurviewID
sqlAuth = "Select AuthID From Admin_Auth Where href='Admin/" & strFileName & "' Order By sort Asc,AuthID Asc"
Call Exec(rsAuth,sqlAuth,2)
If rsAuth.BOF And rsAuth.EOF Then
	PurviewID = 0
Else
	PurviewID = rsAuth(0)
	CheckPurview PurviewID,0
End If
rsAuth.Close
Set rsAuth = Nothing
Select Case Action
Case "Add"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='AdminGroup/Add' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,0
	Else
		CheckPurview rsAuth(0),0
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call AddGroup()
Case "SaveAdd"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='AdminGroup/Insert' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call SaveAdd()
Case "Modify"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='AdminGroup/Edit' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,0
	Else
		CheckPurview rsAuth(0),0
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call Modify()
Case "SaveModify"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='AdminGroup/Update' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call SaveModify()
Case "ModifyPurview"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='AdminGroup/Access' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,0
	Else
		CheckPurview rsAuth(0),0
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call ModifyPurview()
Case "SaveModifyPurview"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='AdminGroup/DoAccess' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call SaveModifyPurview()
Case "AdminState"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='AdminGroup/State' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call AdminState()
Case "Update"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='AdminGroup/Update' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call Update()
Case "Del"
	sqlAuth = "Select AuthID From Admin_Auth Where pid="&PurviewID&" And href='AdminGroup/Del' Order By sort Asc,AuthID Asc"
	Call Exec(rsAuth,sqlAuth,2)
	If rsAuth.BOF And rsAuth.EOF Then
		CheckPurview 0,1
	Else
		CheckPurview rsAuth(0),1
	End If
	rsAuth.Close
	Set rsAuth = Nothing
    Call DelAdmin()
Case Else
    Call Main()
End Select
If FoundErr = True Then
	Call WriteErrMsg(ErrMsg, ComeUrl)
End If
Call CloseConn()

Sub Main()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		Sql = "Select * From ["&Data_Name&"] Order By GroupID Desc"
		Call Exe_Conn(Rs,Sql,1)
		i = 0
		If Rs.BOF And Rs.EOF Then
			data = ""
		Else
			If Request("Page") <> "" Then
				CurrentPage = Code_CLng(Request("Page"))
			Else
				CurrentPage = 1
			End If
			MaxPerPage = Code_CLng(Trim(Request("limit")))
			If MaxPerPage <= 0 Then MaxPerPage = 10
			totalPut = Rs.RecordCount
			If CurrentPage < 1 Then
				CurrentPage = 1
			End If
			If (CurrentPage - 1) * MaxPerPage > totalPut Then
				If (totalPut Mod MaxPerPage) = 0 Then
					CurrentPage = totalPut \ MaxPerPage
				Else
					CurrentPage = totalPut \ MaxPerPage + 1
				End If
			End If
			If CurrentPage > 1 Then
				If (CurrentPage - 1) * MaxPerPage < totalPut Then
					Rs.Move (CurrentPage - 1) * MaxPerPage
				Else
					CurrentPage = 1
				End If
			End If
			Do While Not Rs.Eof
				If Rs("addtime") <> "" Then addtime = Time_Type(Rs("addtime"),1)
				If i=0 Then
					data = data & "{""GroupID"":"&Rs("GroupID")&",""GroupName"":"""&ToUnicode(Rs("GroupName"))&""",""GroupDesc"":"""&ToUnicode(Rs("GroupDesc"))&""",""addtime"":"""&addtime&""",""status"":"""&Rs("status")&"""}"
				Else
					data = data & ",{""GroupID"":"&Rs("GroupID")&",""GroupName"":"""&ToUnicode(Rs("GroupName"))&""",""GroupDesc"":"""&ToUnicode(Rs("GroupDesc"))&""",""addtime"":"""&addtime&""",""status"":"""&Rs("status")&"""}"
				End If
				iCount = iCount + 1
				If iCount >= MaxPerPage Then Exit Do
				Rs.MoveNext
				i=i+1
			Loop
			Rs.Close
		End If
		If totalPut = 0 Then
			Response.Write "{""code"":201,""msg"":""\u65e0\u6570\u636e""}" & vbCrLf
		Else
			Response.Write "{""code"":0,""msg"":""\u83b7\u53d6\u6210\u529f!"",""count"":"&totalPut&",""data"":["&data&"],""rel"":1}" & vbCrLf
		End If
		Response.End()
	Else
		Response.Write "<!DOCTYPE html>" & vbCrLf
		Response.Write "<head>" & vbCrLf
		Response.Write "<title>用户组管理</title>" & vbCrlf
		Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
		Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
		Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
		Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
		Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
		Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
		Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
		Response.Write "<link rel=""stylesheet"" href=""../Style/global.css"" media=""all"">" & vbCrLf
		Response.Write "<link rel=""stylesheet"" href=""../Style/font.css"" media=""all"">" & vbCrLf
		Response.Write "<script type='text/javascript'>" & vbCrLf
		Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
		Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
		Response.Write "</script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
		Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
		Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
		Response.Write "</head>" & vbCrlf
		Response.Write "<body>" & vbCrlf
		Response.Write "<div class=""admin-main layui-anim layui-anim-upbit"">" & vbCrlf
		Response.Write "    <fieldset class=""layui-elem-field layui-field-title"">" & vbCrlf
		Response.Write "        <legend>用户组列表</legend>" & vbCrlf
		Response.Write "    </fieldset>" & vbCrlf
		Response.Write "    <table class=""layui-table"" id=""list"" lay-filter=""list""></table>" & vbCrlf
		Response.Write "</div>" & vbCrlf
		Response.Write "<script type=""text/html"" id=""barDemo"">" & vbCrlf
		Response.Write "    <a href=""?Action=Modify&GroupID={{d.GroupID}}"" class=""layui-btn layui-btn-xs"">编辑</a>" & vbCrlf
		Response.Write "    <a href=""?Action=ModifyPurview&GroupID={{d.GroupID}}"" class=""layui-btn layui-btn-xs"">修改权限</a>" & vbCrlf
		Response.Write "    <a class=""layui-btn layui-btn-danger layui-btn-xs"" lay-event=""del"">删除</a>" & vbCrlf
		Response.Write "</script>" & vbCrlf
		Response.Write "<script type=""text/html"" id=""open"">" & vbCrlf
		Response.Write "    <input type=""checkbox"" name=""status"" value=""{{d.GroupID}}"" lay-skin=""switch"" lay-text=""开启|关闭"" lay-filter=""open"" {{ d.status == '1' ? 'checked' : '' }}>" & vbCrlf
		Response.Write "</script>" & vbCrlf
		Response.Write "<script type=""text/html"" id=""topBtn"">" & vbCrlf
		Response.Write "   <a href=""?Action=Add"" class=""layui-btn layui-btn-sm"">添加用户组</a>" & vbCrlf
		Response.Write "</script>" & vbCrlf
		Response.Write "<script>" & vbCrlf
		Response.Write "    layui.use(['table','form'], function() {" & vbCrlf
		Response.Write "        var table = layui.table,form = layui.form,$ = layui.jquery;" & vbCrlf
		Response.Write "        var tableIn = table.render({" & vbCrlf
		Response.Write "            elem: '#list'," & vbCrlf
		Response.Write "            url: '?Action=Main'," & vbCrlf
		Response.Write "            method:'post'," & vbCrlf
		Response.Write "            toolbar: '#topBtn'," & vbCrlf
		Response.Write "            title:'用户组列表'," & vbCrlf
		Response.Write "            cellMinWidth: 80," & vbCrLf
		Response.Write "            page:true," & vbCrLf
		Response.Write "            cols: [[" & vbCrlf
		Response.Write "                {field:'GroupID', title: '编号', width:80,fixed: true,sort: true}" & vbCrlf
		Response.Write "                ,{field:'GroupName', title: '用户组名', width:180, edit: 'text'}" & vbCrlf
		Response.Write "                ,{field:'GroupDesc', title: '角色描述', width:240, edit: 'text'}" & vbCrlf
		Response.Write "                ,{field:'addtime', title: '添加时间',width:160,sort: true}" & vbCrlf
		Response.Write "                ,{field:'status', title: '状态',width:150,toolbar: '#open'}" & vbCrlf
		Response.Write "                ,{title: '操作', width:200, align:'center', toolbar: '#barDemo'}" & vbCrlf
		Response.Write "            ]]" & vbCrlf
		Response.Write "        });" & vbCrlf
		Response.Write "        form.on('switch(open)', function(obj){" & vbCrlf
		Response.Write "            loading = layer.load(1, {shade: [0.1,'#fff']});" & vbCrlf
		Response.Write "            var GroupID = this.value;" & vbCrlf
		Response.Write "            var status = obj.elem.checked===true?1:0;" & vbCrlf
		Response.Write "            $.ajax({" & vbCrLf
		Response.Write "                type: 'post'," & vbCrLf
		Response.Write "                url: '?Action=AdminState'," & vbCrLf
		Response.Write "                data: {'GroupID':GroupID,'status':status}," & vbCrLf
		Response.Write "                dataType: 'json'," & vbCrLf
		Response.Write "                success: function(res) {" & vbCrLf
		Response.Write "                    layer.close(loading);" & vbCrlf
		Response.Write "                    if (res.code==1) {" & vbCrlf
		Response.Write "                        tableIn.reload();" & vbCrlf
		Response.Write "                    }else{" & vbCrlf
		Response.Write "                        layer.msg(res.msg,{time:1000,icon:2});" & vbCrlf
		Response.Write "                        return false;" & vbCrlf
		Response.Write "                    }" & vbCrLf
		Response.Write "                }" & vbCrLf
		Response.Write "            });" & vbCrLf
		Response.Write "        });" & vbCrlf
		Response.Write "        //监听单元格编辑" & vbCrlf
		Response.Write "        table.on('edit(list)',function(obj) {" & vbCrlf
		Response.Write "            var value = obj.value, data = obj.data, field = obj.field;" & vbCrlf
		Response.Write "            $.ajax({" & vbCrLf
		Response.Write "                type: 'post'," & vbCrLf
		Response.Write "                url: '?Action=Update'," & vbCrLf
		Response.Write "                data: {GroupID:data.GroupID,field:field,value:value}," & vbCrLf
		Response.Write "                dataType: 'json'," & vbCrLf
		Response.Write "                success: function(res) {" & vbCrLf
		Response.Write "                    if (res.code == 1) {" & vbCrlf
		Response.Write "                        layer.msg(res.msg, {time: 1000, icon: 1}, function () {" & vbCrlf
		Response.Write "                            tableIn.reload();" & vbCrlf
		Response.Write "                        });" & vbCrlf
		Response.Write "                    }else{" & vbCrlf
		Response.Write "                        layer.msg(res.msg,{time:1000,icon:2});" & vbCrLf
		Response.Write "                    }" & vbCrlf
		Response.Write "                }" & vbCrLf
		Response.Write "            });" & vbCrLf
		Response.Write "        });" & vbCrlf
		Response.Write "        table.on('tool(list)', function(obj){" & vbCrlf
		Response.Write "            var data = obj.data;" & vbCrlf
		Response.Write "            if(obj.event === 'del'){" & vbCrlf
		Response.Write "                layer.confirm('你确定要删除吗？', function(index){" & vbCrlf
		Response.Write "                    $.ajax({" & vbCrLf
		Response.Write "                        type: 'post'," & vbCrLf
		Response.Write "                        url: '?Action=Del'," & vbCrLf
		Response.Write "                        data: {GroupID:data.GroupID}," & vbCrLf
		Response.Write "                        dataType: 'json'," & vbCrLf
		Response.Write "                        success: function(res) {" & vbCrLf
		Response.Write "                            if (res.code == 1) {" & vbCrLf
		Response.Write "                                layer.msg(res.msg,{time:1000,icon:1});" & vbCrLf
		Response.Write "                                obj.del();" & vbCrLf
		Response.Write "                            }else{" & vbCrLf
		Response.Write "                                layer.msg(res.msg,{time:1000,icon:2});" & vbCrLf
		Response.Write "                            }" & vbCrLf
		Response.Write "                        }" & vbCrLf
		Response.Write "                    });" & vbCrLf
		Response.Write "                    layer.close(index);" & vbCrlf
		Response.Write "                });" & vbCrlf
		Response.Write "            }" & vbCrlf
		Response.Write "        });" & vbCrlf
		Response.Write "    });" & vbCrlf
		Response.Write "</script>" & vbCrlf
		Response.Write "</body>" & vbCrLf & "</html>"
	End If
End Sub

Sub AddGroup()
	Response.Write "<!DOCTYPE html>" & vbCrLf
	Response.Write "<head>" & vbCrLf
	Response.Write "<title>用户组管理</title>" & vbCrLf
	Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
	Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
	Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
	Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
	Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/global.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/font.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<script type='text/javascript'>" & vbCrLf
	Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
	Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
	Response.Write "</script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
	Response.Write "</head>" & vbCrLf
	Response.Write "<body>" & vbCrLf
	Response.Write "<form class='layui-form layui-form-pane' id=""myform"" name=""myform"" method='post' action='" & strFileName & "'>" & vbCrLf
	Response.Write "<div class=""admin-main fadeInUp animated"">" & vbCrlf
	Response.Write "    <fieldset class=""layui-elem-field layui-field-title"">" & vbCrlf
	Response.Write "        <legend>添加用户组</legend>" & vbCrlf
	Response.Write "    </fieldset>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">用户组名：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""GroupName"" type=""text"" id=""GroupName"" size=""30"" maxlength=""30"" value="""" lay-verify=""required"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">角色描述：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""GroupDesc"" type=""text"" id=""GroupDesc"" value="""" lay-verify=""required"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">状态：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input id='status' name='status' type='radio' value='1' checked title='开启' lay-filter='status'><input type='radio' id='status' name='status' value='0' title='关闭' lay-filter='status'>" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "</div>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<input type=""hidden"" name=""Action"" id='Action' value=""SaveAdd""><input name='Scode' type='hidden' id='Scode' value='" & CheckSecretCode("start") & "'>" & Submit_Layui("提交添加","重新填写","确认要清空对话框内容？","javascript:history.back();","返回上一页","") & vbCrlf
	Response.Write "</form>" & vbCrLf
	Response.Write "<script>" & vbCrlf
	Response.Write "layui.use(['form'], function () {" & vbCrlf
	Response.Write "    var form = layui.form;" & vbCrlf
	Response.Write "    //提交监听" & vbCrlf
	Response.Write "    form.on('submit(submit)', function (data) {" & vbCrlf
	Response.Write "        loading = layer.load(1, {shade: [0.1,'#fff']});" & vbCrlf
	Response.Write "        $.ajax({" & vbCrLf
	Response.Write "            type: 'post'," & vbCrLf
	Response.Write "            url: '?Action=SaveAdd'," & vbCrLf
	Response.Write "            data: data.field," & vbCrLf
	Response.Write "            dataType: 'json'," & vbCrLf
	Response.Write "            success: function(res) {" & vbCrLf
	Response.Write "                layer.close(loading);" & vbCrlf
	Response.Write "                if(res.code > 0){" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 1, time: 1000},function(){" & vbCrlf
	Response.Write "                        location.href = res.url;" & vbCrlf
	Response.Write "                    });" & vbCrlf
	Response.Write "                }else{" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 2, time: 1000});" & vbCrlf
	Response.Write "                }" & vbCrlf
	Response.Write "            }" & vbCrLf
	Response.Write "        });" & vbCrLf
	Response.Write "    });" & vbCrlf
	Response.Write "});" & vbCrlf
	Response.Write "</script>" & vbCrlf
	Response.Write "</body>" & vbCrLf & "</html>"
End Sub

Sub Modify()
	Response.Write "<!DOCTYPE html>" & vbCrLf
	Response.Write "<head>" & vbCrLf
	Response.Write "<title>用户组管理</title>" & vbCrLf
	Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
	Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
	Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
	Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
	Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/global.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/font.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<script type='text/javascript'>" & vbCrLf
	Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
	Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
	Response.Write "</script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
	Response.Write "</head>" & vbCrLf
	Response.Write "<body>" & vbCrLf
	Dim GroupID
	Dim rsAdmin, sqlAdmin
	GroupID = Trim(Request("GroupID"))
	If GroupID = "" Then
		Response.Write IsSuccess("请指定要修改的用户组ID！",AdminFolder & "/Admin/"&strFileName)
		Exit Sub
	Else
		GroupID = Code_CLng(GroupID)
	End If
	sqlAdmin = "Select * From ["&Data_Name&"] where GroupID=" & GroupID
	Call Exe_Conn(rsAdmin,sqlAdmin,3)
	If rsAdmin.BOF And rsAdmin.EOF Then
		Response.Write IsSuccess("不存在此用户组！",AdminFolder & "/Admin/"&strFileName)
		rsAdmin.Close
		Set rsAdmin = Nothing
		Exit Sub

	End If
	Response.Write "<form class='layui-form layui-form-pane' id=""myform"" name=""myform"" method='post' action='" & strFileName & "'>" & vbCrLf
	Response.Write "<div class=""admin-main fadeInUp animated"">" & vbCrlf
	Response.Write "    <fieldset class=""layui-elem-field layui-field-title"">" & vbCrlf
	Response.Write "        <legend>修改用户组</legend>" & vbCrlf
	Response.Write "    </fieldset>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">用户组名：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""GroupName"" type=""text"" id=""GroupName"" size=""30"" maxlength=""30"" value=""" & rsAdmin("GroupName") & """ class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "    <div class=""layui-form-item"">" & vbCrlf
	Response.Write "        <label class=""layui-form-label"">角色描述：</label>" & vbCrlf
	Response.Write "        <div class=""layui-input-4"">" & vbCrlf
	Response.Write "            <input name=""GroupDesc"" type=""text"" id=""GroupDesc"" value=""" & rsAdmin("GroupDesc") & """ lay-verify=""required"" class=""layui-input"">" & vbCrlf
	Response.Write "        </div>" & vbCrlf
	Response.Write "    </div>" & vbCrlf
	Response.Write "</div>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<input name='GroupID' type='hidden' value='" & rsAdmin("GroupID") & "'><input type=""hidden"" name=""Action"" id='Action' value=""SaveModify""><input name='Scode' type='hidden' id='Scode' value='" & CheckSecretCode("start") & "'>" & Submit_Layui("提交修改","重新填写","确认要清空对话框内容？","javascript:history.back();","返回上一页","") & vbCrlf
	Response.Write "</form>" & vbCrLf
	Response.Write "<script>" & vbCrlf
	Response.Write "layui.use(['form'], function () {" & vbCrlf
	Response.Write "    var form = layui.form;" & vbCrlf
	Response.Write "    //提交监听" & vbCrlf
	Response.Write "    form.on('submit(submit)', function (data) {" & vbCrlf
	Response.Write "        loading = layer.load(1, {shade: [0.1,'#fff']});" & vbCrlf
	Response.Write "        $.ajax({" & vbCrLf
	Response.Write "            type: 'post'," & vbCrLf
	Response.Write "            url: '?Action=SaveModify'," & vbCrLf
	Response.Write "            data: data.field," & vbCrLf
	Response.Write "            dataType: 'json'," & vbCrLf
	Response.Write "            success: function(res) {" & vbCrLf
	Response.Write "                layer.close(loading);" & vbCrlf
	Response.Write "                if(res.code > 0){" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 1, time: 1000},function(){" & vbCrlf
	Response.Write "                        location.href = res.url;" & vbCrlf
	Response.Write "                    });" & vbCrlf
	Response.Write "                }else{" & vbCrlf
	Response.Write "                    layer.msg(res.msg,{icon: 2, time: 1000});" & vbCrlf
	Response.Write "                }" & vbCrlf
	Response.Write "            }" & vbCrLf
	Response.Write "        });" & vbCrLf
	Response.Write "    });" & vbCrlf
	Response.Write "});" & vbCrlf
	Response.Write "</script>" & vbCrlf
	rsAdmin.Close
	Set rsAdmin = Nothing
	Response.Write "</body>" & vbCrLf & "</html>"
End Sub

Sub ModifyPurview()
	Response.Write "<!DOCTYPE html>" & vbCrLf
	Response.Write "<head>" & vbCrLf
	Response.Write "<title>用户组管理</title>" & vbCrLf
	Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
	Response.Write "<meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-status-bar-style' content='black'>" & vbCrLf
	Response.Write "<meta name='apple-mobile-web-app-capable' content='yes'>" & vbCrLf
	Response.Write "<meta name='format-detection' content='telephone=no'>" & vbCrLf
	Response.Write "<link rel=""stylesheet"" type=""text/css"" href=""../fonts/font-awesome/css/font-awesome.min.css"" />" & vbCrLf
	Response.Write "<link href='../Plugins/layui/css/layui.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/global.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<link href='../Style/font.css' rel='stylesheet' type='text/css' />" & vbCrLf
	Response.Write "<script type='text/javascript'>" & vbCrLf
	Response.Write "var pc_file = '" & InstallDir & "';" & vbCrLf
	Response.Write "var admin_file = '" & AdminFolder & "/';" & vbCrLf
	Response.Write "</script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../Js/Admin.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/main.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcore.min.js'></script>" & vbCrLf
	Response.Write "<script type='text/javascript' src='../../Dialog/lhgcalendar.min.js'></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/layui/layui.js""></script>" & vbCrLf
	Response.Write "</head>" & vbCrLf
	Response.Write "<body>" & vbCrLf
	Dim GroupID
	Dim rsAdmin, sqlAdmin
	Dim PO
	GroupID = Trim(Request("GroupID"))
	If GroupID = "" Then
		Response.Write IsSuccess("请指定要修改的用户组ID！",AdminFolder & "/Admin/"&strFileName)
		Exit Sub
	Else
		GroupID = Code_CLng(GroupID)
	End If

	sqlAdmin = "Select * From ["&Data_Name&"] where GroupID=" & GroupID
	Call Exe_Conn(rsAdmin,sqlAdmin,3)
	If rsAdmin.BOF And rsAdmin.EOF Then
		Response.Write IsSuccess("不存在此用户组！",AdminFolder & "/Admin/"&strFileName)
		rsAdmin.Close
		Set rsAdmin = Nothing
		Exit Sub
	End If

	PO = rsAdmin("rules")
	Response.Write "<form class='layui-form layui-form-pane' id=""myform"" name=""myform"" method='post' action='" & strFileName & "'>"
	Response.Write "<div class=""admin-main layui-anim layui-anim-upbit"">" & vbCrLf
	Response.Write "    <fieldset class=""layui-elem-field"">" & vbCrLf
	Response.Write "        <legend>配置权限</legend>" & vbCrLf
	Response.Write "        <div class=""layui-field-box"">" & vbCrLf
	Response.Write "            <ul id=""treeDemo"" class=""ztree""></ul>" & vbCrLf
	Response.Write "        </div>" & vbCrLf
	Response.Write "    </fieldset>" & vbCrLf
	Response.Write "</div>" & vbCrLf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write "<br>" & vbCrlf
	Response.Write Submit_Layui("提交修改","重新填写","确认要清空对话框内容？","javascript:history.back();","返回上一页","") & vbCrlf
	Response.Write "</form>" & vbCrlf
	If PO <> "" Then
		POlength = Split(PO, ",")
		POlength = ubound(POlength)+1
	Else
		POlength = 0
	End If
	Response.Write "<link rel=""stylesheet"" href=""../Plugins/zTree/css/zTreeStyle.css"" type=""text/css"">" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/zTree/js/jquery.ztree.core.min.js""></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"" src=""../Plugins/zTree/js/jquery.ztree.excheck.min.js""></script>" & vbCrLf
	Response.Write "<script type=""text/javascript"">" & vbCrLf
	Response.Write "    var setting = {" & vbCrLf
	Response.Write "        check:{enable: true}," & vbCrLf
	Response.Write "        view: {showLine: false, showIcon: false, dblClickExpand: false}," & vbCrLf
	Response.Write "        data: {" & vbCrLf
	Response.Write "            simpleData: {enable: true, pIdKey:'pid', idKey:'id'}," & vbCrLf
	Response.Write "            key:{name:'title'}" & vbCrLf
	Response.Write "        }" & vbCrLf
	Response.Write "    };" & vbCrLf
	Response.Write "    var zNodes =["
	sql = "select * from Admin_Auth Order By sort Asc,AuthID Asc"
	Call Exe_Conn(rs,sql,1)
	AuthtotalPut = Rs.RecordCount
	Response.Write "{""id"":0,""pid"":0,""title"":"""&ToUnicode("全部")&""""
	If AuthtotalPut = POlength Then
		Response.Write ",""checked"":true"
	End If
	Response.Write ",""open"":true}"
	Do while not Rs.eof
		Response.Write ",{""id"":"&rs("AuthID")&",""pid"":"&rs("pid")&",""title"":"""&ToUnicode(rs("title"))&""""
		If CheckPurview_Other(PO, rs("AuthID")) = True Then
			Response.Write ",""checked"":true"
		End If
		Response.Write ",""open"":true}"
		Rs.MoveNext
	Loop
	Set Rs=Nothing
	Response.Write "];" & vbCrLf
	Response.Write "    function setCheck() {" & vbCrLf
	Response.Write "        var zTree = $.fn.zTree.getZTreeObj(""treeDemo"");" & vbCrLf
	Response.Write "        zTree.setting.check.chkboxType = { ""Y"":""ps"", ""N"":""ps""};" & vbCrLf
	Response.Write "    }" & vbCrLf
	Response.Write "    $.fn.zTree.init($(""#treeDemo""), setting, zNodes);" & vbCrLf
	Response.Write "    setCheck();" & vbCrLf
	If POlength > 0 And POlength < AuthtotalPut Then
		Response.Write "    $(document).ready(function() {" & vbCrLf
		Response.Write "        $('#treeDemo_1_check').addClass(""checkbox_true_part"");" & vbCrLf
		Response.Write "    });" & vbCrLf
	End If
	Response.Write "    layui.use(['form', 'layer'], function () {" & vbCrLf
	Response.Write "        var form = layui.form, layer = layui.layer;" & vbCrLf
	Response.Write "        form.on('submit(submit)', function () {" & vbCrLf
	Response.Write "            loading = layer.load(1, {shade: [0.1,'#fff']});" & vbCrLf
	Response.Write "            // 提交到方法 默认为本身" & vbCrLf
	Response.Write "            var treeObj=$.fn.zTree.getZTreeObj(""treeDemo"")," & vbCrLf
	Response.Write "                nodes=treeObj.getCheckedNodes(true)," & vbCrLf
	Response.Write "                v="""";" & vbCrLf
	Response.Write "            for(var i=1;i<nodes.length;i++){" & vbCrLf
	Response.Write "                if (i == 1) {" & vbCrLf
	Response.Write "                    v+=nodes[i].id;" & vbCrLf
	Response.Write "                }else{" & vbCrLf
	Response.Write "                    v+="","" + nodes[i].id;" & vbCrLf
	Response.Write "                }" & vbCrLf
	Response.Write "            }" & vbCrLf
	Response.Write "            var id = """&rsAdmin("GroupID")&""";" & vbCrLf
	Response.Write "            $.ajax({" & vbCrLf
	Response.Write "                type: 'post'," & vbCrLf
	Response.Write "                url: '?Action=SaveModifyPurview'," & vbCrLf
	Response.Write "                data: {'rules':v,'GroupID':id,'Scode':'" & CheckSecretCode("start") & "'}," & vbCrLf
	Response.Write "                dataType: 'json'," & vbCrLf
	Response.Write "                success: function(res) {" & vbCrLf
	Response.Write "                    layer.close(loading);" & vbCrlf
	Response.Write "                    if(res.code > 0){" & vbCrlf
	Response.Write "                        layer.msg(res.msg,{icon: 1, time: 1000},function(){" & vbCrlf
	Response.Write "                            location.href = res.url;" & vbCrlf
	Response.Write "                        });" & vbCrlf
	Response.Write "                    }else{" & vbCrlf
	Response.Write "                        layer.msg(res.msg,{icon: 2, time: 1000});" & vbCrlf
	Response.Write "                    }" & vbCrlf
	Response.Write "                }" & vbCrLf
	Response.Write "            });" & vbCrLf
	Response.Write "        })" & vbCrLf
	Response.Write "    });" & vbCrLf
	Response.Write "</script>" & vbCrLf
	rsAdmin.Close
	Set rsAdmin = Nothing
	Response.Write "</body>" & vbCrLf & "</html>"
End Sub

Sub SaveAdd()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		Dim GroupName, rules
		Dim rsAdmin, sqlAdmin

		'验证安全码
		If CheckSecretCode(Trim(Request.Form("Scode"))) <> True Then
			Response.Write "{""code"":0,""msg"":""\u975e\u6cd5\u63d0\u4ea4\u7684\u6570\u636e\uff01""}" & vbCrLf
			Response.End()
		End If

		GroupName = Trim(Request("GroupName"))
		GroupDesc = Trim(Request("GroupDesc"))
		status = Trim(Request("status"))

		If GroupName = "" Then
			Response.Write "{""code"":0,""msg"":""\u7528\u6237\u7ec4\u540d\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		
		If FoundErr = True Then Exit Sub
		
		GroupID = GetNewID(Data_Name, "GroupID")
		sqlAdmin = "Select * From ["&Data_Name&"] where GroupName='" & GroupName & "'"
		Call Exe_Conn(rsAdmin,sqlAdmin,3)
		If Not (rsAdmin.BOF And rsAdmin.EOF) Then
			Response.Write "{""code"":0,""msg"":""\u6570\u636e\u5e93\u4e2d\u5df2\u7ecf\u5b58\u5728\u6b64\u7528\u6237\u7ec4\uff01""}" & vbCrLf
			Response.End()
			rsAdmin.Close
			Set rsAdmin = Nothing
			Exit Sub
		End If
		
		rsAdmin.addnew
		rsAdmin("GroupID") = GroupID
		rsAdmin("GroupName") = GroupName
		rsAdmin("GroupDesc") = GroupDesc
		rsAdmin("status") = status
		rsAdmin("addtime") = Time_Type(now(),1)
		rsAdmin.Update
		rsAdmin.Close
		Set rsAdmin = Nothing
		Response.Write "{""code"":1,""msg"":""\u6dfb\u52a0\u6210\u529f\uff01"",""url"":""?""}" & vbCrLf
		Response.End()
	End If
End Sub

Sub SaveModify()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		Dim GroupID, GroupName, Password, PwdConfirm
		Dim rsAdmin, sqlAdmin
		
		'验证安全码
		If CheckSecretCode(Trim(Request.Form("Scode"))) <> True Then
			Response.Write "{""code"":0,""msg"":""\u975e\u6cd5\u63d0\u4ea4\u7684\u6570\u636e\uff01""}" & vbCrLf
			Response.End()
		End If

		GroupID = Trim(Request("GroupID"))
		GroupName = Trim(Request("GroupName"))
		GroupDesc = Trim(Request("GroupDesc"))
		If GroupID = "" Then
			Response.Write "{""code"":0,""msg"":""\u8bf7\u6307\u5b9a\u8981\u4fee\u6539\u7684\u7528\u6237\u7ec4ID\uff01""}" & vbCrLf
			Response.End()
		Else
			GroupID = Code_CLng(GroupID)
		End If
		If GroupName = "" Then
			Response.Write "{""code"":0,""msg"":""\u7528\u6237\u7ec4\u540d\u4e0d\u80fd\u4e3a\u7a7a\uff01""}" & vbCrLf
			Response.End()
		End If
		
		If FoundErr = True Then Exit Sub
		
		sqlAdmin = "Select * From ["&Data_Name&"] where GroupID=" & GroupID
		Call Exe_Conn(rsAdmin,sqlAdmin,3)
		If rsAdmin.BOF And rsAdmin.EOF Then
			Response.Write "{""code"":0,""msg"":""\u4e0d\u5b58\u5728\u6b64\u7528\u6237\u7ec4\uff01""}" & vbCrLf
			Response.End()
			rsAdmin.Close
			Set rsAdmin = Nothing
			Exit Sub
		End If
		rsAdmin("GroupName") = GroupName
		rsAdmin("GroupDesc") = GroupDesc
		rsAdmin.Update
		rsAdmin.Close
		Set rsAdmin = Nothing
		Response.Write "{""code"":1,""msg"":""\u4fee\u6539\u6210\u529f\uff01"",""url"":""?""}" & vbCrLf
		Response.End()
	End If
End Sub

Sub SaveModifyPurview()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		Dim GroupID, rules
		Dim rsAdmin, sqlAdmin

		'验证安全码
		If CheckSecretCode(Trim(Request.Form("Scode"))) <> True Then
			Response.Write "{""code"":0,""msg"":""\u975e\u6cd5\u63d0\u4ea4\u7684\u6570\u636e\uff01""}" & vbCrLf
			Response.End()
		End If
		
		GroupID = Trim(Request("GroupID"))
		rules = ReplaceBadChar(Trim(Request("rules")))
		
		If GroupID = "" Then
			Response.Write "{""code"":0,""msg"":""\u8bf7\u6307\u5b9a\u8981\u4fee\u6539\u7684\u7528\u6237\u7ec4ID\uff01""}" & vbCrLf
			Response.End()
		Else
			GroupID = Code_CLng(GroupID)
		End If
		
		If FoundErr = True Then Exit Sub
		
		sqlAdmin = "Select * From ["&Data_Name&"] where GroupID=" & GroupID
		Call Exe_Conn(rsAdmin,sqlAdmin,3)
		If rsAdmin.BOF And rsAdmin.EOF Then
			Response.Write "{""code"":0,""msg"":""\u4e0d\u5b58\u5728\u6b64\u7528\u6237\u7ec4\uff01""}" & vbCrLf
			Response.End()
			rsAdmin.Close
			Set rsAdmin = Nothing
			Exit Sub
		End If
		rsAdmin("rules") = Replace(rules," ","")
		rsAdmin.Update
		rsAdmin.Close
		Set rsAdmin = Nothing
		Response.Write "{""code"":1,""msg"":""\u4fee\u6539\u6210\u529f\uff01"",""url"":""?""}" & vbCrLf
		Response.End()
	End If
End Sub

Sub AdminState()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		GroupID = Code_CLng(Trim(Code_Form("GroupID")))
		If GroupID = "" Then
			Response.Write "{""code"":0,""msg"":""\u8bf7\u6307\u5b9a\u8981\u4fee\u6539\u7684\u7528\u6237\u7ec4ID\uff01""}" & vbCrLf
			Response.End()
		Else
			GroupID = Code_CLng(GroupID)
		End If
		status = Trim(Code_Form("status"))
		Call Exec("","Update ["&Data_Name&"] Set status="&status&" Where GroupID="&GroupID,0)
		Response.Write "{""msg"":""\u4fee\u6539\u6210\u529f"",""code"":1}"
		Response.End()
	End If
End Sub

Sub Update()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		Dim GroupID
		GroupID = Trim(Code_Form("GroupID"))
		field = Trim(Code_Form("field"))
		value = Trim(Code_Form("value"))
		If GroupID = "" Then
			Response.Write "{""msg"":""\u8bf7\u6307\u5b9a\u8981\u5220\u9664\u7684\u6765\u6e90ID\uff01"",""code"":0}"
			Response.End()
		End If
		Call Exec("","Update ["&Data_Name&"] Set "&field&"='"&value&"' where GroupID=" & GroupID,0)
		Response.Write "{""msg"":""\u7f16\u8f91\u6210\u529f\uff01"",""code"":1}"
		Response.End()
	End If
End Sub

Sub DelAdmin()
	If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
		Dim GroupID
		Dim rsAdmin, sqlAdmin

		'验证安全码
		'If CheckSecretCode(Trim(Request.Form("Scode"))) <> True Then
			'Response.Write "{""msg"":""\u975e\u6cd5\u63d0\u4ea4\u7684\u6570\u636e\uff01"",""code"":0}"
			'Response.End()
		'End If

		GroupID = Trim(Request.Form("GroupID"))
		If GroupID = "" Then
			Response.Write "{""msg"":""\u8bf7\u6307\u5b9a\u8981\u5220\u9664\u7684\u7528\u6237\u7ec4ID\uff01"",""code"":0}"
			Response.End()
		End If
		If InStr(GroupID, ",") > 0 Then
			Call Exec("","delete From ["&Data_Name&"] where GroupID in (" & GroupID & ")",0)
		Else
			Call Exec("","delete From ["&Data_Name&"] where GroupID=" & GroupID & "",0)
		End If
		Response.Write "{""msg"":""\u5220\u9664\u6210\u529f\uff01"",""code"":1}"
		Response.End()
	End If
End Sub
%>